package cn.tedu.modules;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @Author: Miyako
 * @Date: 2024-07-30-15:13
 * @Description: connection工具类
 */
public class DBUtil {
   private String dB="tedu";

    DBUtil(){

    }
    DBUtil(String dB){
        this.dB=dB;
    }
    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

   public  Connection getConnection () throws SQLException {
        return DriverManager.getConnection("jdbc:mysql://localhost:3306" +
                "/"+this.dB+"?characterEncoding=utf8&useSSL=false&serverTimezone=Asia" +
                "/Shanghai&rewriteBatchedStatements=true","root","root");

    }

}
